package com.lht.designPattern.observer;

import java.util.Observable;

/**
 * @author Eric
 * @version 1.0
 * @date 2019-06-13
 */
public class Bell extends Observable {

    public void bell(){
        System.out.println("-----------------------上课拉------------------------");
        notifyObservers();
    }


    public  static void main(String[] args){
        Bell bell=new Bell();


        //注册监听者
        bell.addObserver(new Student("小明"));
        bell.addObserver(new Student("小花"));
        bell.addObserver(new Student("小张"));
        bell.addObserver(new Teacher("张老师"));
        //设置为变更了
        bell.setChanged();

        //打铃了，大家都回教室吧
        bell.bell();
        bell.clearChanged();
    }
}
